#include <bits/stdc++.h>
using namespace std;
vector<int> nums, temp, ans;

void  merge_sort(vector<int> &nums, int l, int r) {
	if (l >= r) {
		return;
	}
	int mid = (l + r) / 2;
	merge_sort(nums, l, mid);
	merge_sort(nums, mid + 1, r);
	int k = 0,  i = l, j = mid + 1;
	while (l <= mid && j <= r) {
		if (nums[i] <= nums[j]) {
			temp[k++] = nums[i++];
		} else {
			temp[k++] = nums[j++];
			ans.push_back(mid - i + 1);
		}
	}
	while (l <= mid) {
		temp[k++] = nums[i++];
	}
	while (j <= r) {
		temp[k++] = nums[j++];
	}
	for (int i = l, j = 0; i <= r; ++i, ++j) {
		nums[i] = temp[j];
	}
}

vector<int> countSmaller(vector<int> &nums) {
	int n = nums.size();
	merge_sort(nums, 0, n - 1);
	return ans;
}



int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		nums.push_back(x);
	}
	auto c = countSmaller(nums);
	for (int i = c.size() - 1; i >= 0; --i) {
		cout << c[i];
	}
	return 0;
}